#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>

int main()
{
	int n, s = 0;
	scanf("%d", &n);
	if (n > 30 || n < 10)
		printf("0");
	else
	{
		int a, b, c, d, e, f, g, h, i, j;
		int step = 0;
		int arr[9999][10];
		for (a = 1; a <= 3; a++)
			for (b = 1; b <= 3; b++)
				for (c = 1; c <= 3; c++)
					for (d = 1; d <= 3; d++)
						for (e = 1; e <= 3; e++)
							for (f = 1; f <= 3; f++)
								for (g = 1; g <= 3; g++)
									for (h = 1; h <= 3; h++)
										for (i = 1; i <= 3; i++)
											for (j = 1; j <= 3; j++)
											{
												if (a + b + c + d + e + f + g + h + i + j == n)
												{
													step++;
													arr[step][0] = a;
													arr[step][1] = b;
													arr[step][2] = c;
													arr[step][3] = d;
													arr[step][4] = e;
													arr[step][5] = f;
													arr[step][6] = g;
													arr[step][7] = h;
													arr[step][8] = i;
													arr[step][9] = j;
												}
											}
		printf("%d\n", step);
		for (int t = 1; t <= step;t++)
		{
			for (int q = 0; q < 10; q++)
			{
				printf("%d ", arr[t][q]);
			}
			printf("\n");
		}
	}
	return 0;
}